package cn.edu.sgu.www.mhxysy.feign.interceptor;

import cn.edu.sgu.www.mhxysy.config.property.FeignHeaderProperties;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * feign请求头拦截器
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Component
public class RequestHeaderInterceptor implements RequestInterceptor {

    private final String headerName;
    private final String headerValue;

    @Autowired
    public RequestHeaderInterceptor(FeignHeaderProperties feignHeaderProperties) {
        headerName = feignHeaderProperties.getName();
        headerValue = feignHeaderProperties.getValue();
    }

    @Override
    public void apply(RequestTemplate template) {
        template.header(headerName, headerValue);
    }

}